package com.vecspace.data.model;

import java.util.List;

/**用于Service和Controller封装返回数据(带主数据项)<br>
 * List&lt;T&gt; 查询结果列表数据 <br>
 * R 主数据 <br>
 * List&lt;S&gt; 查询结果聚合数据 <br>
 * @version 1.0
 * @author wanghua
 * @reviewer  
 * @createTime 2021年9月7日 下午2:48:35
 */
public class ListExBO<T, R, S> extends ListBO<T>{
	/**主数据项*/
	private R mainData;

	/**聚合（统计）查询结果 */
	private List<S> aggregations;
	
	public ListExBO() {
		
	}

	public ListExBO(R mainData, List<T> items) {
		this.setMainData(mainData);
		this.setItems(items);
	}
	
	public ListExBO(R mainData, List<T> items, IPagination pager) {
		this.setMainData(mainData);
		this.setItems(items);
		this.setPager(pager);
	}
	
	public ListExBO(List<T> items, List<S> aggregations, IPagination pager) {
		this.setItems(items);
		this.setAggregations(aggregations);
		this.setPager(pager);
	}
	
	public static <T, R> ListExBO<T, R, Void> newInstance(R mainData, List<T> items){
		return new ListExBO<T, R, Void>(mainData, items);
	}

	public static <T, R> ListExBO<T, R, Void> newInstance(R mainData, List<T> items, IPagination pager){
		return new ListExBO<T, R, Void>(mainData, items, pager);
	}

	public static <T, S> ListExBO<T, Void, S> newInstance(List<T> items, List<S> aggregations, IPagination pager){
		return new ListExBO<T, Void, S>(items, aggregations, pager);
	}

	public R getMainData() {
		return mainData;
	}

	public void setMainData(R mainData) {
		this.mainData = mainData;
	}

	public List<S> getAggregations() {
		return aggregations;
	}

	public void setAggregations(List<S> aggregations) {
		this.aggregations = aggregations;
	}
}
